<template>
  <div class="search">
    <f-form ref="form" :action="api.adv" :form-key="this.formItem.advId" >
      <f-form-item label="广告名称"  name="advName" dataType="${formField.dataType}"   :value="formItem.advName" />
      <f-form-item label="图片"  name="advImg" dataType="${formField.dataType}"   :value="formItem.advImg" />
      <f-form-item label="发布状态 0:未发布 1:已发布"  name="advStatus" dataType="number"   :value="formItem.advStatus" />
      <f-form-item label="内容"  name="content" dataType="${formField.dataType}"   :value="formItem.content" />
      <f-form-item label="首页广告1,商城广告2,3弹屏广告"  name="advType" dataType="${formField.dataType}"   :value="formItem.advType" />
      <f-form-item label=""  name="goodsId" dataType="${formField.dataType}"   :value="formItem.goodsId" />
      <f-form-item label=""  name="sort" dataType="number"   :value="formItem.sort" />
      <f-form-item label="跳转方式"  name="jumpType" dataType="number"   :value="formItem.jumpType" />
      <f-form-item label=""  name="isCanBuy" dataType="number"   :value="formItem.isCanBuy" />
      <f-form-item label=""  name="weChatId" dataType="${formField.dataType}"   :value="formItem.weChatId" />
      <f-form-item label="是否删除"  name="deleted" dataType="number"   :value="formItem.deleted" />
      <f-form-item label="更新人"  name="updateUser" dataType="${formField.dataType}"   :value="formItem.updateUser" />
      <f-form-item label="更新时间"  name="updateTime" dataType="${formField.dataType}"   :value="formItem.updateTime" />
      <f-form-item label="创建人"  name="createUser" dataType="${formField.dataType}"   :value="formItem.createUser" />
      <f-form-item label="创建时间"  name="createTime" dataType="${formField.dataType}"   :value="formItem.createTime" />
    </f-form>
  </div>
</template>
<script>
  import api from './js/api'
  export default {
    name: 'advForm',
    props: {},
    data() {
      return {
        refs:this.$refs,
        api:  Object.assign(api, this.api),
        isAdd: true,//是否是添加模式
        loaded: false,//是否加载完成
        formItem: this.getFormItem()
      }
    },
    methods: {
      getFormItem() {
        return {
          advId: '',
          advName: '',
          advImg: '',
          advStatus: '',
          content: '',
          advType: '',
          goodsId: '',
          sort: '',
          jumpType: '',
          isCanBuy: '',
          weChatId: '',
          deleted: '',
          updateUser: '',
          updateTime: '',
          createUser: '',
          createTime: ''
        }
      },
      //表单赋值
      setData(data) {
        this.$refs.form.resetFields()
        this.formItem = this.getFormItem()
        if (data && data.advId) {
          let params={
              advId:data.advId
          }
          this.refs['form'].getDetails(params,(data)=>{
             this.formItem=data
             this.loaded = true
          })
          this.isAdd = false
        } else {
          this.loaded = true
        }
      },
      //提交表单
      handleSubmit(callback) {
        this.$refs.form.submit({  }, callback)
      }
    },
    created() {
    },
    components: {}
  }
</script>

<style scoped lang="less" rel="stylesheet/less">

</style>
